<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title>弹窗</title>
    <style>
      html, body, div, span, applet, object, iframe,
      h1, h2, h3, h4, h5, h6, p, blockquote, pre,
      a, abbr, acronym, address, big, cite, code,
      del, dfn, em, img, ins, kbd, q, s, samp,
      small, strike, strong, sub, sup, tt, var,
      b, u, i, center,
      dl, dt, dd, ol, ul, li,
      fieldset, form, label, legend,
      table, caption, tbody, tfoot, thead, tr, th, td,
      article, aside, canvas, details, embed,
      figure, figcaption, footer, header,
      menu, nav, output, ruby, section, summary,
      time, mark, audio, video, input {
          margin: 0;
          padding: 0;
          border: 0;
          font-size: 100%;
          font-weight: normal;
          vertical-align: baseline;
      }
      body {
          line-height: 1;
      }
      .dialog-ui{
        position: fixed;
        top:0;
        left: 0;
        bottom:0;
        right: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: rgba(0, 0, 0, .6)
      }
      .dialog{
        width:80%;
        background-color: #fff;
      }
      .dialog .title{
        line-height: 35px;
        color: #666;
        padding-left: 15px;
        padding-bottom: 10px;
      }
      .dialog .button{
        display: flex;
      }
      .dialog .content{
        padding: 15px;
        line-height: 20px;
        min-height: 40px;
        color:#333;
        font-size:14px;
      }
      .dialog .button {
        padding-bottom: 20px;
      }
      .dialog .button .btn{
        display: inline-block;
        margin:0 15px;
        background-color: #666;
        color:#fff;
        line-height: 35px;
        width:50%;
        text-align: center;
        font-size:14px;
        text-decoration: none;
        border:1px solid #333;
      }
      .dialog .button .btn:last-child{
        background-color: #333;
      }

      .dialog-ui-ios{
        position: fixed;
        top:0;
        left: 0;
        bottom:0;
        right: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: #fff
      }
      .dialog-ui-ios-item{
        padding-left: 20px;
        padding-right: 20px;
        flex-direction: column;
        justify-content: space-between;
        display: flex;
      }
      .dialog-ui-ios-down{
        background-color: #16a8f8;
        color: white;
        text-align: center;
        height: 50px;
        line-height:50px;
        width: 180px;
        text-decoration:none;
        border-radius: 25px;
        margin-left: 20%;
        margin-right: 20%;
        margin-top: 20px;
      }
    </style>
    
  </head>
  <body>
    <p id="test"></p>
    <div class="dialog-ui" id="andriod-ui" style="display: none;">
      <div class="dialog">
        <div class="title">提示</div>
        <div class="content">
          你确定要更新吗？
        </div>
        <div class="button">
          <a href="" class="btn">取消</a>
          <a href="https://wt.139xy.cn/apk/xyqb.apk" class="btn" >更新</a>
        </div>
      </div>
    </div>

    <div class="dialog-ui-ios" id="ios-ui" style="display: none;"> 
      <div class="dialog-ui-ios-item">
        <p style=" font-size: 15px; line-height: 20px;">
            尊敬的IOS用户：享宇钱包系统升级，该版本即将停止服务，
            为了不影响您的使用，请尽快前往浏览器下载最新版本！
            也可关注享宇钱包微信公众号使用借款服务。
            下载安装到手机后依次点击“设置”-->“通用”-->“描述文件”-->“应用”-点击信任。
        </p>

       <p id="test1"></p>
        <a href="itms-services://?action=download-manifest&url=https://wt.139xy.cn/rainbow_wallets/src/resources/manifest.plist"
         class="btn dialog-ui-ios-down">去 下 载</a>
        <a href="./src/html/install-step.html"
         class="btn dialog-ui-ios-down">安装指南</a> 
      </div>
    </div>
  </body>
  <script>
      function detectOS () {
        let systemInfo = {}
        let sUserAgent = navigator.userAgent
        let isWin = (navigator.platform === 'Win32') || (navigator.platform === 'Windows')
        let isMac = (navigator.platform === 'Mac68K') || (navigator.platform === 'MacPPC') || (navigator.platform === 'Macintosh') || (navigator.platform === 'MacIntel')
        if (isMac) systemInfo.system = 'Mac'
        let isUnix = (navigator.platform === 'X11') && !isWin && !isMac
        if (isUnix) systemInfo.system = 'Unix'
        let isLinux = (String(navigator.platform).indexOf('Linux') > -1)
        let bIsAndroid = sUserAgent.toLowerCase().match(/android/i) === 'android'
        let isAndroid = sUserAgent.indexOf('Android') !== -1
        let isIos = !!sUserAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
        if (isIos) {
          let tempVer = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/)
          systemInfo.osType = '02'
          systemInfo.system = 'IOS'
          systemInfo.version = parseInt(tempVer[1], 10)
        } else if (isAndroid) {
          systemInfo.osType = '01'
          systemInfo.system = 'Android'
        } else if (isLinux) {
          if (bIsAndroid) {
            systemInfo.osType = '01'
            systemInfo.system = 'Android'
            systemInfo.version = sUserAgent.substr(sUserAgent.indexOf('Android') + 8, 5)
          } else {
            systemInfo.osType = '04'
            systemInfo.system = 'Linux'
          }
        } else if (isWin) {
          systemInfo.osType = '03'
          let system
          let is64 = sUserAgent.indexOf('WOW64') > -1
          let isWin2K = sUserAgent.indexOf('Windows NT 5.0') > -1 || sUserAgent.indexOf('Windows 2000') > -1
          if (isWin2K) system = 'Win2000'
          let isWinXP = sUserAgent.indexOf('Windows NT 5.1') > -1 || sUserAgent.indexOf('Windows XP') > -1
          sUserAgent.indexOf('Windows XP') > -1
          if (isWinXP) system = 'WinXP'
          let isWin2003 = sUserAgent.indexOf('Windows NT 5.2') > -1 || sUserAgent.indexOf('Windows 2003') > -1
          if (isWin2003) system = 'Win2003'
          let isWinVista = sUserAgent.indexOf('Windows NT 6.0') > -1 || sUserAgent.indexOf('Windows Vista') > -1
          if (isWinVista) system = 'WinVista'
          let isWin7 = sUserAgent.indexOf('Windows NT 6.1') > -1 || sUserAgent.indexOf('Windows 7') > -1
          if (isWin7) system = 'Win7'
          let isWin8 = sUserAgent.indexOf('windows nt6.2') > -1 || sUserAgent.indexOf('Windows 8') > -1
          if (isWin8) system = 'Win8'
          systemInfo.system = system
          if (is64) {
            systemInfo.version = '64位'
          } else {
            systemInfo.version = '32位'
          }
        } else {
          systemInfo.system = '其他'
        }
        
        return systemInfo
    }
    // var osType = detectOS();
    // alert(osType.system);
    // alert(osType.osType);

    let sUserAgent = navigator.userAgent
    let isIos = !!sUserAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
    let isAndroid =  sUserAgent.indexOf('Android') > -1 || sUserAgent.indexOf('Linux') > -1 || sUserAgent.toLowerCase().match(/android/i) === 'android'
    if (!isAndroid) {
      document.getElementById('andriod-ui').style.display = 'none';
      document.getElementById('ios-ui').style.display = 'flex';
    }else{
      document.getElementById('andriod-ui').style.display = 'flex';
      document.getElementById('ios-ui').style.display = 'none';
    }

    document.getElementById('test').innerText = 'ios:' + isIos + ';android:' + isAndroid;
    document.getElementById('test1').innerText = 'ios:' + isIos + ';android:' + isAndroid;
    </script>
</html>
